home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Angled Carets and Hilites.c next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.6 KB  |  108 lines  |  [TEXT/KAHL]

  1. /* 1.0D2 -- change transfer modes from gxXorMode to gxFastXorMode
  2.             and change SetShapeCommonTransfer to SetShapeFastTransfer */
  3.  
  4. #include <Types.h>
  5. #include <QuickDraw.h>
  6. #include <Fonts.h>
  7. #include <Windows.h>
  8. #include <Menus.h>
  9. #include <SegLoad.h>
  10. #include <Memory.h>
  11. #include <Desk.h>
  12.  
  13. #include "graphics routines.h"
  14. #include "graphics libraries.h"
  15. #include "graphics toolbox.h"
  16.  
  17. #include "layout types.h"
  18. #include "layout routines.h"
  19. #include "layout library.h"
  20.  
  21. #include "SampleInterface.h"
  22.  
  23. short MyStrLen(char *x);
  24. static short MyStrLen(x)
  25. char    *x;
  26.     {
  27.     short c = 0;
  28.     while (*x++) c++;
  29.     return c;
  30.     }    /* MyStrLen */
  31.  
  32. void AngledCaretsAndHilites(WindowPtr sampleWindow)
  33.     {
  34.     /* Variables */
  35.     char            *myString = "Intrinsically Angled Text";
  36.     gxPoint            myPoint;
  37.     gxRunControls        gxRunControls;
  38.     gxShape            caret, highlight, layout;
  39.     short            i, len, level = 0;
  40.     gxStyle            myStyle;
  41.     gxViewPort        aViewPort;
  42.     
  43.     /* Initialization */
  44.     
  45.     myPoint.x = ff(20);
  46.     myPoint.y = ff(50);
  47.     
  48.     aViewPort = GXNewWindowViewPort(sampleWindow);
  49.     SetDefaultViewPort(aViewPort);
  50.     
  51.     len = MyStrLen(myString);
  52.     InitializeRunControls(&gxRunControls);
  53.  
  54.     myStyle = NewLayoutStyle((char *) "\pZapf Chancery Medium Italic", ff(50), 0, nil, nil, 0, nil);
  55.     
  56.     layout = GXNewLayout(
  57.         1, &len, (void *) &myString,
  58.         1, &len, &myStyle,
  59.         1, &len, &level,
  60.         nil, &myPoint);
  61.     GXDrawShape(layout);
  62.     
  63.     for (i = 0; i <= len; i++)
  64.         {
  65.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  66.         GXDrawShape(caret);
  67.         GXDisposeShape(caret);
  68.         }
  69.     
  70.     gxRunControls.flags = gxNoCaretAngle;
  71.     GXSetStyleRunControls(myStyle, &gxRunControls);
  72.     GXMoveShape(layout, 0, ff(75));
  73.     GXDrawShape(layout);
  74.     
  75.     for (i = 0; i <= len; i++)
  76.         {
  77.         caret = GXGetLayoutCaret(layout, i, gxHighlightAverageAngle, gxSplitCaretType, nil);
  78.         GXDrawShape(caret);
  79.         GXDisposeShape(caret);
  80.         }
  81.     
  82.     gxRunControls.flags = 0;
  83.     GXSetStyleRunControls(myStyle, &gxRunControls);
  84.     GXMoveShape(layout, 0, ff(75));
  85.     GXDrawShape(layout);
  86.     
  87.     highlight = GXGetLayoutHighlight(layout, 5, 11, gxHighlightAverageAngle, nil);
  88.     /* changed to make this invert */
  89.     SetShapeFastXorTransfer(highlight, NULL, NULL);
  90.     GXDrawShape(highlight);
  91.     GXDisposeShape(highlight);
  92.     
  93.     gxRunControls.flags = gxNoCaretAngle;
  94.     GXSetStyleRunControls(myStyle, &gxRunControls);
  95.     GXMoveShape(layout, 0, ff(75));
  96.     GXDrawShape(layout);
  97.     
  98.     highlight = GXGetLayoutHighlight(layout, 5, 11, gxHighlightAverageAngle, nil);
  99.     /* changed to make this invert */
  100.     SetShapeFastXorTransfer(highlight, NULL, NULL);
  101.     GXDrawShape(highlight);
  102.     GXDisposeShape(highlight);
  103.     
  104.     GXDisposeShape(layout);
  105.     GXDisposeStyle(myStyle);
  106.     GXDisposeViewPort(aViewPort);
  107.     }    /* main */
  108.